var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("BaseModuleUI"),
    a = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = e("AssetsManager"),
    s = e("AudioManager"),
    l = e("Game"),
    c = e("UIManager"),
    d = e("AD"),
    h = cc._decorator,
    _ = h.ccclass,
    u = h.property,
    p = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.level_icon = null),
                (t.get_over_node = null),
                (t.get_btn_node = null),
                (t.video_btn = null),
                (t.award_over_node = null),
                (t.video_over_node = null),
                (t.mask_node = null),
                (t.award_node_info = []),
                (t.video_node_info = []),
                (t.season_index = 0),
                (t.season_award_info = null),
                (t.uiManager = null),
                t
            );
        }
        return (
            __extends(t, e),
            (t.prototype.initView = function () {
                this.uiManager = cc.find("UIManager").getComponent(c.default);
            }),
            (t.prototype.showSeasonInfo = function (e) {
                (this.season_index = e), (this.node.zIndex = e);
                var t = i.GlobalParams.PlayerInfo.value;
                (this.level_icon.spriteFrame = r.default.getInstance().getPlayerLevelExp(this.season_index)),
                    (this.mask_node.active = t.level < this.season_index);
                var o = l.default.season_info[e - 1];
                this.season_award_info = o;
                for (var n = 0; n < 5; n++)
                    (this.award_node_info[n].active = !1), (this.video_node_info[n].active = !1);
                for (n = 0; n < 9; n++) {
                    var a = null,
                        s = null;
                    0 == n || 1 == n
                        ? ((a = this.award_node_info[n]), (s = this.video_node_info[n]))
                        : 7 == n
                        ? ((a = this.award_node_info[3]), (s = this.video_node_info[3]))
                        : 8 == n
                        ? ((a = this.award_node_info[4]), (s = this.video_node_info[4]))
                        : ((a = this.award_node_info[2]), (s = this.video_node_info[2]));
                    var c = -1 != o.award_type.indexOf(n) ? o.award_num[o.award_type.indexOf(n)] : 0;
                    a.active ||
                        ((a.active = c > 0),
                        (a.getChildByName("num").getComponent(cc.Label).string = "" + c),
                        a.active &&
                            -1 == [0, 1, 7, 8].indexOf(n) &&
                            (a.children[0].getComponent(cc.Sprite).spriteFrame = r.default
                                .getInstance()
                                .getDowerImagerFrame("dower_" + (n - 2) + "_0")));
                    var d = -1 != o.extra_type.indexOf(n) ? o.extra_num[o.extra_type.indexOf(n)] : 0;
                    s.active ||
                        ((s.active = d > 0),
                        (s.getChildByName("num").getComponent(cc.Label).string = "" + d),
                        s.active &&
                            -1 == [0, 1, 7, 8].indexOf(n) &&
                            (s.children[0].getComponent(cc.Sprite).spriteFrame = r.default
                                .getInstance()
                                .getDowerImagerFrame("dower_" + (n - 2) + "_0")));
                }
                (this.award_node_info[0].parent.active =
                    this.award_node_info[0].active || this.award_node_info[1].active),
                    (this.award_node_info[2].parent.active =
                        this.award_node_info[2].active ||
                        this.award_node_info[3].active ||
                        this.award_node_info[4].active),
                    (this.video_node_info[0].parent.active =
                        this.video_node_info[0].active || this.video_node_info[1].active),
                    (this.video_node_info[2].parent.active =
                        this.video_node_info[2].active ||
                        this.video_node_info[3].active ||
                        this.video_node_info[4].active),
                    (this.get_btn_node.active = -1 == i.GlobalParams.PlayerSeasonInfo.value.free_award.indexOf(e)),
                    (this.get_over_node.active = !this.get_btn_node.active),
                    (this.video_btn.active = -1 == i.GlobalParams.PlayerSeasonInfo.value.extra_award.indexOf(e)),
                    (this.video_over_node.active = !this.video_btn.active),
                    this.get_btn_node.on("click", this.showGetAward, this),
                    this.video_btn.on("click", this.getExtraAward, this);
            }),
            (t.prototype.showGetAward = function () {
                for (var e = 0; e < 9; e++)
                    if (-1 != this.season_award_info.award_type.indexOf(e))
                        if (0 == e || 1 == e)
                            -1 != this.season_award_info.award_type.indexOf(e) &&
                                this.uiManager.addCoinAni(
                                    this.season_award_info.award_num[this.season_award_info.award_type.indexOf(e)],
                                    e
                                );
                        else if (7 == e) {
                            var t = i.GlobalParams.PlayerInfo.value,
                                o = Number(t.revive);
                            (o += Number(
                                this.season_award_info.award_num[this.season_award_info.award_type.indexOf(e)]
                            )),
                                (t.revive = o),
                                (i.GlobalParams.PlayerInfo.value = t),
                                this.emitEvent(a.default.UPDATE_HAVE_REVIVE_NUMBER);
                        } else if (8 == e) {
                            var n = i.GlobalParams.playerSkinInfo.value;
                            (n.have.taste_card +=
                                this.season_award_info.award_num[this.season_award_info.award_type.indexOf(e)]),
                                (i.GlobalParams.playerSkinInfo.value = n),
                                this.emitEvent(a.default.UPDATE_HAVE_TASTE_CARD_NUMBER);
                        } else {
                            var r = i.GlobalParams.PlayerDowerInfo.value;
                            (r.debris[e - 2] +=
                                this.season_award_info.award_num[this.season_award_info.award_type.indexOf(e)]),
                                (i.GlobalParams.PlayerDowerInfo.value = r);
                        }
                var s = i.GlobalParams.PlayerSeasonInfo.value;
                s.free_award.push(this.season_index),
                    (i.GlobalParams.PlayerSeasonInfo.value = s),
                    this.showSeasonInfo(this.season_index);
            }),
            (t.prototype.getExtraAward = function () {
                var e = this;
                d.default.getInstance().showVideo(function (t) {
                    if ((s.default.playGameBGM(), t == d.ResultEnum.Success)) {
                        for (var o = 0; o < 9; o++)
                            if (-1 != e.season_award_info.extra_type.indexOf(o))
                                if (0 == o || 1 == o)
                                    -1 != e.season_award_info.extra_type.indexOf(o) &&
                                        e.uiManager.addCoinAni(
                                            e.season_award_info.extra_num[e.season_award_info.extra_type.indexOf(o)],
                                            o
                                        );
                                else if (7 == o) {
                                    var n = i.GlobalParams.PlayerInfo.value,
                                        r = Number(n.revive);
                                    (r += Number(
                                        e.season_award_info.extra_num[e.season_award_info.extra_type.indexOf(o)]
                                    )),
                                        (n.revive = r),
                                        (i.GlobalParams.PlayerInfo.value = n),
                                        e.emitEvent(a.default.UPDATE_HAVE_REVIVE_NUMBER);
                                } else if (8 == o) {
                                    var l = i.GlobalParams.playerSkinInfo.value;
                                    (l.have.taste_card +=
                                        e.season_award_info.extra_num[e.season_award_info.extra_type.indexOf(o)]),
                                        (i.GlobalParams.playerSkinInfo.value = l),
                                        e.emitEvent(a.default.UPDATE_HAVE_TASTE_CARD_NUMBER);
                                } else {
                                    var c = i.GlobalParams.PlayerDowerInfo.value;
                                    (c.debris[o - 2] +=
                                        e.season_award_info.extra_num[e.season_award_info.extra_type.indexOf(o)]),
                                        (i.GlobalParams.PlayerDowerInfo.value = c);
                                }
                        var h = i.GlobalParams.PlayerSeasonInfo.value;
                        h.extra_award.push(e.season_index),
                            (i.GlobalParams.PlayerSeasonInfo.value = h),
                            e.showSeasonInfo(e.season_index);
                    }
                });
            }),
            __decorate([u(cc.Sprite)], t.prototype, "level_icon", void 0),
            __decorate([u(cc.Node)], t.prototype, "get_over_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "get_btn_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "video_btn", void 0),
            __decorate([u(cc.Node)], t.prototype, "award_over_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "video_over_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "mask_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "award_node_info", void 0),
            __decorate([u(cc.Node)], t.prototype, "video_node_info", void 0),
            __decorate([_], t)
        );
    })(n.default);
o.default = p;
